﻿<%@ Control Language="C#" ClassName="ProductLinkControl" %>

<script runat="server">
  //public string ProductPrice
  //{
  //  set
  //  {
  //    Literal_price.Text = value;
  //  }
  //}

  //public string ProductInfo
  //{
  //  set
  //  {
  //    Literal_info.Text = value;
  //  }
  //}

  //public string ProductImageUrl
  //{
  //  set
  //  {
  //    Img1.Src = value;
  //  }
  //}
  //public string ProductLink
  //{
  //  set
  //  {
  //    Product_link.HRef = value;
  //  }
  //}

  //public string LightStatus
  //{
  //  set
  //  {
  //    Literal_newhot.Text = CommonUtil.GetNEWAndHOT(value);
  //  }
  //}

  public dynamic Prd_Ary { get; set; }
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      if (Prd_Ary != null)
      {
        ImgProd.Src = Prd_Ary.IMAGE_PATH_M;
        ImgProd.Alt = Prd_Ary.B2C_CODE_NAME;
        Product_link.HRef = "~/Products/ProductDetail.aspx?B2C_CODE=" + Prd_Ary.B2C_CODE;
        Literal_info.Text = Prd_Ary.B2C_CODE_NAME;
        Literal_price.Text = Prd_Ary.ACT_PRICE.ToString("n0");
        Literal_newhot.Text = CommonUtil.GetNEWAndHOT(Prd_Ary.light_status.ToString());
        if (Prd_Ary.MbrPrice != 0 || !string.IsNullOrEmpty(Prd_Ary.MbrPrice.ToString()))
        {
          Literal_MbrPrice.Text = CommonUtil.GetMemberPrice(Prd_Ary.MbrPrice.ToString());
        }

        string Output_Prod_Cat_ID = Prd_Ary.Output_Prod_Cat_ID.ToString();
        switch (Output_Prod_Cat_ID)
        {
          case "1"://1:哩上加禮
            Lit_MileagePrice.Text = Prd_Ary.ACT_PRICE.ToString("n0");
            string CASH = Prd_Ary.CASH != null ? Prd_Ary.CASH.ToString("n0") : Prd_Ary.ACT_PRICE.ToString("n0");
            string MILEAGE = Prd_Ary.MILEAGE != null ? Prd_Ary.MILEAGE.ToString() : "0";
            Lit_MILEAGE.Text = CASH + " + " + MILEAGE;
            divMileage.Visible = true;
            break;
          case "2"://2:紅配綠
            divMember.Visible = true;
            break;
          case "3"://3:限時折扣(整點特賣)
            string Time_Dsc_Price = Prd_Ary.Time_Dsc_Price != null ? Prd_Ary.Time_Dsc_Price.ToString("n0") : Prd_Ary.ACT_PRICE.ToString("n0");
            Lit_TimeDscPrice.Text = Time_Dsc_Price;
            string START_range = Prd_Ary.START_DATE_range != null ? Prd_Ary.START_DATE_range.ToString("yyyy/MM/dd") : "2014/2/1";
            string START_DATE_range = Prd_Ary.START_DATE_range != null ? Prd_Ary.START_DATE_range.ToString("t") : "00:00:00";
            string END_DATE_range = Prd_Ary.END_DATE_range != null ? Prd_Ary.END_DATE_range.ToString("t") : "12:00:00";
            Lit_DATE_range.Text = START_range + " " + START_DATE_range + "~" + END_DATE_range;
            divClock.Visible = true;
            break;
          case "4"://4:期間限定
            string RangeDscPrice = Prd_Ary.RangeDscPrice != null ? Prd_Ary.RangeDscPrice.ToString("n0") : Prd_Ary.ACT_PRICE.ToString("n0");
            Lit_RangeDscPrice.Text = RangeDscPrice;
            string START_DATE = Prd_Ary.START_DATE != null ? Prd_Ary.START_DATE.ToString("yyyy/MM/dd") : "2014/2/1";
            string END_DATE = Prd_Ary.END_DATE != null ? Prd_Ary.END_DATE.ToString("yyyy/MM/dd") : "9999/12/31";
            Lit_DATE.Text = START_DATE + " ~ " + END_DATE;
            divPeriod.Visible = true;
            break;
          default: //0:一般
            divMember.Visible = true;
            break;
        }
      }
      else
      {
        ImgProd.Src = "~/Images/ContentImages/home_delivery-coming_soon.jpg";
        Product_link.HRef = "javascript:void(0);";
      }
    }
  }
 
</script>

<a href="#" id="Product_link" runat="server">
  <img src="#" id="ImgProd" runat="server" />
  <div class="release">
    <asp:Literal ID="Literal_newhot" runat="server" Mode="PassThrough"></asp:Literal>
  </div>
  <div class="description">
    <div class="price" id="divMember" runat="server" visible="false">
      特價 $ <strong>
        <asp:Literal ID="Literal_price" runat="server" Mode="PassThrough" />
      </strong>
      <asp:Literal ID="Literal_MbrPrice" runat="server" Mode="PassThrough" />
    </div>
    <div class="price" id="divPeriod" runat="server" visible="false">
      期間限定價 $ <strong>
        <asp:Literal ID="Lit_RangeDscPrice" runat="server" /></strong>
      <b>
        <p class="orange-text">
          <asp:Literal ID="Lit_DATE" runat="server" /></p>
      </b>
    </div>
    <div class="price" id="divClock" runat="server" visible="false">
      限時優惠價 $ <strong>
        <asp:Literal ID="Lit_TimeDscPrice" runat="server" /></strong>
      <b>
        <p class="orange-text">
          <asp:Literal ID="Lit_DATE_range" runat="server" /></p>
      </b>
    </div>
    <div class="price" id="divMileage" runat="server" visible="false">
      特價 $ <strong>
        <asp:Literal ID="Lit_MileagePrice" runat="server" /></strong>
      <b>
        <p class="orange-text">或 $
          <asp:Literal ID="Lit_MILEAGE" runat="server" />
          哩</p>
      </b>
    </div>
    <div class="info">
      <p>
        <asp:Literal ID="Literal_info" runat="server" Mode="PassThrough"></asp:Literal>
      </p>
    </div>
  </div>
</a>

